function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split( ';' );
	for( var i=0; i < ca.length; i++ ) 
	{
		var c = ca[i];
		while ( c.charAt(0) == ' ') c = c.substring( 1, c.length );
		if ( c.indexOf( nameEQ ) == 0 ) return c.substring( nameEQ.length, c.length );
	}
	
	return null;
}

function setCookie()
{
	var the_date = new Date();
	the_date.setDate( the_date.getDate() + 5 );
	var cookie_date = the_date.toGMTString();
	var the_cookie = "users_resolution=" + screen.width + "x" + screen.height;
	var the_cookie = the_cookie + ";expires=" + cookie_date;
	var the_cookie_width = "users_width=" + screen.width;
	var the_cookie_width = the_cookie_width + ";expires=" + cookie_date;
	document.cookie = the_cookie;
	document.cookie = the_cookie_width;
}

function checkCookie()
{
	var width = screen.width + "";
	var check = readCookie( 'users_width' );
	
	if( !check )
	{
		//alert('No Cookie set!');
		setCookie();
		location = './index.php';
	}
	else if( check != width )
	{
		//alert('Reload your browser! You changed your resolution!');
		setCookie();
		location = './index.php';

	}
	else
	{
		return;
	}
	
}
